from pydantic_settings import BaseSettings
from typing import Optional
import os


class Settings(BaseSettings):
    # 数据库配置
    database_url: str = "mysql+pymysql://xiaojia:123456@192.168.37.11:3306/mailspeed"
    database_host: str = "192.168.37.11"
    database_port: int = 3306
    database_user: str = "xiaojia"
    database_password: str = "123456"
    database_name: str = "mailspeed"
    
    # Redis配置
    redis_url: str = "redis://:123456@192.168.37.11:6379/0"
    redis_host: str = "192.168.37.11"
    redis_port: int = 6379
    redis_password: str = "123456"
    redis_db: int = 0
    
    # JWT配置
    secret_key: str = "your-secret-key-here-change-in-production"
    algorithm: str = "HS256"
    access_token_expire_minutes: int = 30

    # 文件上传配置
    upload_dir: str = "./uploads"
    max_file_size: int = 10485760  # 10MB

    # 应用配置
    app_name: str = "邮件统一发送平台"
    app_version: str = "1.0.0"
    debug: bool = True
    
    # 邮件配置
    default_smtp_host: str = "smtp.qq.com"
    default_smtp_port: int = 587
    default_smtp_user: str = "1163218095@qq.com"
    default_smtp_password: str = ""
    default_use_tls: bool = True
    default_use_ssl: bool = False
    
    class Config:
        env_file = ".env"
        case_sensitive = False


# 创建全局设置实例
settings = Settings()

# 确保上传目录存在
os.makedirs(settings.upload_dir, exist_ok=True)
